package hos.ui.bean;



import java.util.ArrayList;
import java.util.List;

/**
 * <p>Title: CheckSingle </p>
 * <p>Description:  </p>
 * <p>Company: www.mapuni.com </p>
 *
 * @author : 蔡俊峰
 * @version : 1.0
 * @date : 2023/5/17 15:09
 */
public class CheckSingle {
    private List<String> titles = new ArrayList<>();
    private List<String> codes = new ArrayList<>();

    private List<Object> tags = new ArrayList<>();

    private int index = -1;
    private String id;

    public CheckSingle(String id) {
        this.id = id;
    }

    public CheckSingle() {
        this("CheckSingle");
    }

    public CheckSingle(List<String> titles, List<String> codes) {
        this();
        this.titles = titles;
        this.codes = codes;
    }

    public CheckSingle(String id, List<String> titles, List<String> codes) {
        this.id = id;
        this.titles = titles;
        this.codes = codes;
    }

    public List<String> getTitles() {
        return titles;
    }
    public String[] getTitleArray() {
        return titles.toArray(new String[]{});
    }

    public List<String> getCodes() {
        return codes;
    }

    public List<Object> getTags() {
        return tags;
    }

    public void setTags(List<Object> tags) {
        this.tags = tags;
    }

    public int getIndex() {
        return index;
    }

    public String getId() {
        return id;
    }

    public String title(int index) {
        if (index < 0 || titles.isEmpty() || titles.size() <= index) {
            return null;
        }
        return titles.get(index);
    }

    public String code(int index) {
        if (index < 0 || codes.isEmpty() || codes.size() <= index) {
            return null;
        }
        return codes.get(index);
    }

    public String check(int index) {
        this.index = index;
        return code(index);
    }

    public String getCode() {
        if (index >= codes.size()) {
            return "";
        }
        return code(index);
    }

    public void clear() {
        titles.clear();
        codes.clear();
        index = -1;
    }

    public void clearCheck() {
        index = -1;
    }
}
